package com.wuxiaofan.coupon.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.coupon.entity.SmsCoupon;
import com.wuxiaofan.coupon.entity.custom.SmsCouponCustom;
import com.wuxiaofan.coupon.mapper.SmsCouponMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.coupon.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class SmsCouponService {
    @Autowired
    private SmsCouponMapper smsCouponMapper;
    @Resource
    private Idgenerator idgenerator;
    public SmsCoupon findById(String id){
        return smsCouponMapper.selectById(id);
    }

    public SmsCouponCustom findCountByMap(Map paraMap){
        return smsCouponMapper.findCountByMap(paraMap);
    }

    public SmsCouponCustom findGroupByMap(Map paraMap){
        return smsCouponMapper.findGroupByMap(paraMap);
    }

    public List<SmsCouponCustom> findByMap(Map paraMap){
        return smsCouponMapper.findByMap(paraMap);
    }

    public Page<SmsCouponCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(smsCouponMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        smsCouponMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        smsCouponMapper.deleteById(id);
    }

    public SmsCoupon save(SmsCoupon smsCoupon){
        smsCoupon.setId(idgenerator.getId());
        smsCouponMapper.insert(smsCoupon);
        return smsCoupon;
    }

}
